package com.ocom.payconfig.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.entity.payconfig.EntityFoodstuffPurchase;
import com.ocom.common.request.payconfig.food.GetFoodPurchaseListRequest;
import com.ocom.common.request.payconfig.food.RemoveFoodPurchaseRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.payconfig.service.FoodstuffPurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class FoodPurchaseController {

    @Autowired
    FoodstuffPurchaseService foodstuffPurchaseService;

    //11.12.1食材采购单列表（getFoodPurchaseList）
    @PostMapping(PayConfigUrl.Url_getFoodPurchaseList)
    public Result getFoodPurchaseList(@RequestBody GetFoodPurchaseListRequest request){

        return ResultUtil.success(foodstuffPurchaseService.getList(request.getComId(), request));
    }

    //11.12.2删除食材采购单（removeFoodPurchase）
    @PostMapping(PayConfigUrl.Url_removeFoodPurchase)
    public Result removeFoodPurchase(@RequestBody RemoveFoodPurchaseRequest request){

        foodstuffPurchaseService.removeFoodPurchase(request.getComId(), request);

        return ResultUtil.success();
    }

    //11.12.3增加食材采购单（newFoodPurchase）
    @PostMapping(PayConfigUrl.Url_newFoodPurchase)
    public Result newFoodPurchase(@RequestBody EntityFoodstuffPurchase entityFoodstuffPurchase){
        foodstuffPurchaseService.newFoodPurchase(entityFoodstuffPurchase.getComId(), entityFoodstuffPurchase);

        return ResultUtil.success();
    }

    //11.12.4修改食材采购单（updateFoodPurchase）
    @PostMapping(PayConfigUrl.Url_updateFoodPurchase)
    public Result updateFoodPurchase(@RequestBody EntityFoodstuffPurchase entityFoodstuffPurchase){
        foodstuffPurchaseService.updateFoodPurchase(entityFoodstuffPurchase.getComId(), entityFoodstuffPurchase);
        return ResultUtil.success();
    }


}
